import { getCache, setCache } from "#server/utils/context"; import { getCategoryById } from "../../service/category"; export default defineWrappedResponseHandler(async (event) => { const id = getRouterParam(event, "id"); if (!id) return R.throwError(400, "Missing id", null); const cacheKey = `category:${id}`; const cached = await getCache(cacheKey); if (cached) return R.success(cached); const category = await getCategoryById(id); if (!category) return R.throwError(404, "Category not found", null); await setCache(cacheKey, category, 120); return R.success(category); });